﻿Shader "GJ/OutLine"
{
    Properties
    {
        _OutlineColor("描边颜色",Color)=(1,1,1,1)
        _OutlineWidth("描边宽",Range(1,10))=1
 
    }
    SubShader
    {
        Tags{
            "Queue"="Transparent"
            "IgnoreProjector"="True"
            "RenderType"="Transparent"
        }
        Cull Off Lighting Off ZWrite Off
        Blend SrcAlpha OneMinusSrcAlpha
        Pass
        {
            CGPROGRAM
            #pragma vertex vert
            #pragma fragment frag
            #include "UnityCG.cginc"
            #include "UnityLightingCommon.cginc"
            fixed4 _MainColor;
 
            struct a2v
            {
                float4 vertex:POSITION;
            };
 
            struct v2f
            {
                float4 pos:SV_POSITION;
            };
 
            v2f vert(a2v v)
            {
                v2f o;
 
                o.pos = UnityObjectToClipPos(v.vertex);
                return o;
            }
 
            fixed4 frag(v2f i):SV_Target
            {
                return (0,0,0,0);
            }
            ENDCG
        }
        //模型扩充渲染
        Pass
        {
            ZWrite off
            Cull Front
            CGPROGRAM
            #pragma vertex vert
            #pragma fragment frag
            #include "UnityCG.cginc"
            float4 _MainColor;
            fixed4 _OutlineColor;
            fixed _OutlineWidth;
 
            struct a2v
            {
                float4 vertex:POSITION;
            };
 
            struct v2f
            {
                float4 pos:SV_POSITION;
            };
 
      
            v2f vert(a2v v)
            {
                v2f o;
                v.vertex.xyz+=v.vertex.xyz * _OutlineWidth * 0.01f;
                o.pos = UnityObjectToClipPos(v.vertex);                
                return o;
            }
            
            fixed4 frag():SV_Target
            {                                
                return _OutlineColor;
            }
            ENDCG
        }
 
    }
}